﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RealState.BLL;
using log4net;
using RealState.BusinessObjects;

namespace RealState.W.uc
{
    public partial class ListContents : System.Web.UI.UserControl
    {
        private VwContentsBLL contentsBLL;
        private List<VwContents> listContent;
        protected ILog log = LogManager.GetLogger("ListContents");
        protected void Page_Load(object sender, EventArgs e)
        {
            string cid = Request.QueryString["CID"];

            if (string.IsNullOrEmpty(cid))
            {
                 cid = "17";
            }
            
            //LoadContent(Convert.ToInt32(cid));
        }
        [System.Web.Services.WebMethod]
        public List<VwContents> GetContent(string cid)
        {
            contentsBLL = new VwContentsBLL();
            try
            {
                listContent = contentsBLL.GetViewContents().Where(v => v.CategoryId == Int32.Parse(cid)).ToList();
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
            }
            return listContent;
        }

        //public void LoadContent(int cid)
        //{
        //    contentsBLL = new VwContentsBLL();
        //    try
        //    {
        //        listContent= contentsBLL.GetViewContents().Where(v => v.CategoryId == cid).ToList();
        //        Repeater1.DataSource = listContent;
        //        Repeater1.DataBind();
        //    }
        //    catch (Exception ex)
        //    {
        //        log.Debug(ex.Message);
        //    }
        //}
    }
}